﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ExtraOpdrachten
{
    public partial class Opdracht3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// Shows the result of the addition of 2 numbers.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnPlus_Click(object sender, EventArgs e)
        {
            double getal1 = double.Parse(txtFirstNumber.Text);
            double getal2 = double.Parse(txtSecondNumber.Text);
            lblResult.Text = getal1.ToString() + " plus " +
                getal2.ToString() + " = " + (getal1 + getal2).ToString();
        }

        /// <summary>
        /// Shows the result of the subtraction of 2 numbers.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnMin_Click(object sender, EventArgs e)
        {
            double getal1 = double.Parse(txtFirstNumber.Text);
            double getal2 = double.Parse(txtSecondNumber.Text);
            lblResult.Text = getal1.ToString() + " min " +
                getal2.ToString() + " = " + (getal1 - getal2).ToString();
        }

        /// <summary>
        /// Shows the result of the mulitplication of 2 numbers.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnMultiply_Click(object sender, EventArgs e)
        {
            double getal1 = double.Parse(txtFirstNumber.Text);
            double getal2 = double.Parse(txtSecondNumber.Text);
            lblResult.Text = getal1.ToString() + " maal " +
                getal2.ToString() + " = " + (getal1 * getal2).ToString();
        }

        /// <summary>
        /// Shows the result of the division of 2 numbers.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnDivide_Click(object sender, EventArgs e)
        {
            double getal1 = double.Parse(txtFirstNumber.Text);
            double getal2 = double.Parse(txtSecondNumber.Text);
            double uitkomst = Math.Round(getal1 / getal2, 2);
            lblResult.Text = getal1.ToString() + " gedeeld door " +
                getal2.ToString() + " = " + uitkomst.ToString("n2");
        }

        /// <summary>
        /// Shows the modulus of 2 numbers.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnMod_Click(object sender, EventArgs e)
        {
            double getal1 = double.Parse(txtFirstNumber.Text);
            double getal2 = double.Parse(txtSecondNumber.Text);
            lblResult.Text = "Als je " + getal1.ToString() + " deelt door " +
                getal2.ToString() + " blijft er " + (getal1 % getal2).ToString() +
                " over.";
        }

        /// <summary>
        /// Handles the Click event of the btnPow control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnPow_Click(object sender, EventArgs e)
        {
            double getal1 = double.Parse(txtFirstNumber.Text);
            double getal2 = double.Parse(txtSecondNumber.Text);
            lblResult.Text = getal1.ToString() + " tot de macht " +
                getal2.ToString() + " = " + Math.Pow(getal1, getal2).ToString();
        }
    }
}